package com.langsin.crmpro.action;

import java.util.List;
import java.util.Map;

import com.langsin.crmpro.base.BaseAction;
import com.langsin.crmpro.manager.CompanyManager;
import com.langsin.crmpro.model.CCompany;
import com.langsin.crmpro.utils.SpellCnHelper;

public class CompanyAction  extends BaseAction {
	
	private static final long serialVersionUID = -4697564521462137620L;

	private CCompany company;
	
	private String name;

	private CompanyManager companyManager;
	
	
	public String load4AddCompany() throws Exception{
		Map $codeAndTime = this.companyManager.getCode();
		
		this.attr("todayStr", $codeAndTime.get("todayStr"));
		this.attr("c_time", $codeAndTime.get("c_time"));
		
		//数据字典表相对应的取出来
		List sDictionaryDetailList = this.companyManager.sDictionaryDetailList();
		this.attr("sDictionaryDetailList", sDictionaryDetailList);
		
		//取得省份列表
		List sProvinceList = this.companyManager.sProvinceList();
		this.attr("sProvinceList", sProvinceList);
		return this.SUCCESS;
		
	}
	public String addCompany() throws Exception
	{
		String[] params = null;
		synchronized(CompanyAction.class)
		{
			params = this.companyManager.addCompany(this.getCompany());
		}
		if(params[1] == null){
			this.addActionMessage("添加成功！");
		}else{
			this.addActionMessage("添加成功！客户编号更新为" + params[1] +".不影响使用！");
		}
		return SUCCESS;
	}
	
	public String getPyCode()throws Exception
	{
		this.name = SpellCnHelper.converterToFirstSpell(this.name);
		
		return SUCCESS;
	}
	
	public CCompany getCompany()
	{
		return company;
	}
	public void setCompany(CCompany company)
	{
		this.company = company;
	}
	public void setCompanyManager(CompanyManager companyManager) {
		this.companyManager = companyManager;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
}
